// add by yanyj 20180724 start
// 封装的Layer类

// 公共类
class BaseLayer {

    constructor(name) {
        this.name =  name || '';
        this.layer =  null;
        this.map = null;
        this.featureType = null;
        this.state = null;
        this.$form = null;
        this.fetch = null;
    }
    // 初始化方法
    init() {
        return this;
    }

    register() {

    }

    setLayer(layer) {
        this.layer = layer;
        return this;
    }

    // 改变状态，触发action
    setState(key, value) {
        this.state.setState(key, value);
        return this;
    }

    setStateAndAction(state, action) {
        this.state = new State(state, action);

        return this;
    }

    addFeatures(data) {

        this.map.removeAllFeatures(this.layer);
        this.map.addFeatures(this.layer, this.createFeatures(data));
        return this;
    }

    //
    createFeatures(data) {
        return [];
    }

    setName(name) {
        this.name = name;
        return this;
    }
    getLayer() {
        return this.layer;
    }

    getName() {
        return this.name;
    }

    setMap(map){
        this.map = map;
    }

    getFormData() {
        if(this.$form && this.$form instanceof $) {
            return this.$form.serializeObject();
        } else {
            return {};
        }
    }

    getClickFeatureEvent() {
        return function () {
            
        }
    }
}


// add by yanyj 20180724 end